package com.mc.web.controller.gpm;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mc.common.annotation.Log;
import com.mc.common.core.controller.BaseController;
import com.mc.common.core.domain.AjaxResult;
import com.mc.common.enums.BusinessType;
import com.mc.gpm.domain.GpmOutStorage;
import com.mc.gpm.service.IGpmOutStorageService;
import com.mc.common.utils.poi.ExcelUtil;
import com.mc.common.core.page.TableDataInfo;

/**
 * 种质资源出库Controller
 *
 * @author mc
 * @date 2021-03-19
 */
@RestController
@RequestMapping("/gpm/outStorage")
public class GpmOutStorageController extends BaseController
{
    @Autowired
    private IGpmOutStorageService gpmOutStorageService;

    /**
     * 查询种质资源出库列表
     */
    @PreAuthorize("@ss.hasPermi('gpm:storage:list')")
    @GetMapping("/list")
    public TableDataInfo list(GpmOutStorage gpmOutStorage)
    {
        startPage();
        List<GpmOutStorage> list = gpmOutStorageService.selectGpmOutStorageList(gpmOutStorage);
        return getDataTable(list);
    }

    /**
     * 导出种质资源出库列表
     */
    @PreAuthorize("@ss.hasPermi('gpm:storage:export')")
    @Log(title = "种质资源出库", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GpmOutStorage gpmOutStorage)
    {
        List<GpmOutStorage> list = gpmOutStorageService.selectGpmOutStorageList(gpmOutStorage);
        ExcelUtil<GpmOutStorage> util = new ExcelUtil<GpmOutStorage>(GpmOutStorage.class);
        return util.exportExcel(list, "storage");
    }

    /**
     * 获取种质资源出库详细信息
     */
    @PreAuthorize("@ss.hasPermi('gpm:storage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(gpmOutStorageService.selectGpmOutStorageById(id));
    }

    /**
     * 新增种质资源出库
     */
    @PreAuthorize("@ss.hasPermi('gpm:storage:add')")
    @Log(title = "种质资源出库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GpmOutStorage gpmOutStorage)
    {
        return toAjax(gpmOutStorageService.insertGpmOutStorage(gpmOutStorage));
    }

}